<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <!-- 画布 -->
    <canvas></canvas>

    <script>
        //1. 获取 canvas 标签
        let canvas = document.querySelector('canvas');
        //设置画布的宽度和高度
        canvas.width = 375;
        canvas.height = 667;

        //2. 获取画笔对象
        let ctx = canvas.getContext('2d');
        ctx.lineWidth = 5;
        ctx.strokeStyle = 'red';

        //3. 调用方法, 绘制图形
        ctx.beginPath(); //开始绘制

        //4. 移动画笔
        ctx.moveTo(100, 100);

        //5. 绘线
        ctx.lineTo(300, 100);
        ctx.lineTo(300, 250);
        ctx.lineTo(100, 100);

        //6. 描边
        ctx.stroke();
    </script>
</body>
</html>